package com.cmc.cloud.cmclink.doc.api.document;

import cn.hutool.core.collection.CollectionUtil;
import com.cmc.cloud.cmclink.doc.api.document.rep.PortDescInfoRespDTO;
import com.cmc.cloud.cmclink.doc.convert.PortDescConvert;
import com.cmc.cloud.cmclink.doc.mapper.PortDescMapper;
import com.cmc.cloud.cmclink.doc.service.PortDescService;
import com.cmc.cloud.cmclink.doc.vo.portdesc.PortDescInfoRespVO;
import com.cmes.framework.common.pojo.CommonResult;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.Collections;
import java.util.List;

/**
 * @author lcp
 * @date 2025/7/7
 */
@RestController
public class PortDescApiImpl implements PortDescApi {

    @Resource
    private PortDescMapper portDescMapper;

    @Resource
    private PortDescService portDescService;

    @Override
    public CommonResult<List<PortDescInfoRespDTO>> queryPortDesc(List<String> portCodes) {
        if (CollectionUtil.isEmpty(portCodes)) {
            return CommonResult.success(Collections.emptyList());
        }
        List<PortDescInfoRespVO> portDescDoList = portDescService.getPortDescInfo(portCodes);
        return CommonResult.success(PortDescConvert.INSTANCE.convertPortDescRespDto(portDescDoList));
    }
}
